@extends('layouts.app')
@section('title', config('seo_title').'-注册')
@section('header')
     @include('common.header')
@stop
@section('footer')
     @include('common.footer')
@stop
@section('content')
<div class="banner1"></div>
<div class="dlxq">
    <h2 style="padding-left: 75px">注册</h2>
    <form id="form1" method="POST" action="{{ route('register') }}">
     {{ csrf_field() }}
        <ul>
            <li><span>手机号码</span><i><input class="wby1" id="tel" name="mobile" placeholder="请输入您的手机号" type="text"></i></li>

            <li><span>验证码</span><i><input class="wby3" id="inputCode" name="" style="float:left;" type="text"></i>
                <i>
                    <div class="code" id="checkCode" onclick="createCode()">{!!captcha_img()!!}</div>
                </i>
            </li>
            <li><a class="hyz" href="javascript:;" onclick="createCode()">看不清换一张</a></li>
            <li><span>手机验证码</span>
                <i><input class="wby2" id="returnCode" name="code" type="text"></i>
                <i><input class="btn2" name="" type="button" onclick="sendsms()" value="发送手机验证码"></i>
            </li>
            <li><span>密码</span><i><input class="wby1" id="pwd" name="password" placeholder="请设置密码" type="password"></i></li>
            <li><p><input id="agree" name="" type="checkbox" value="">
                我已阅读并同意<a class="btnxy" href="#" onclick="agree()">《纺织品名片宝用户协议》</a></p>
            </li>
            <li><i><input style="margin-left: 90px; width: 340px;" class="btn1" id="Button1" name="" onclick="reg1();" type="button" value="注册"></i>
            </li>
        </ul>
    </form>
</div>
<script type="text/javascript">

function reg1()
{
	var mobile = $('#tel').val();
	var password = $('#pwd').val();
	if(password.length < 6)
	{
	layer.msg('密码长度不少于6位.');
	return false;
	}
	if(!checkMobile(mobile))
	{
    layer.msg('请填写正确的手机号.');
    return false;
	}
	var inputCode = $('#returnCode').val();
	if(inputCode.length != 4)
		{
		layer.msg('请填正确手机验证码.');
		return false;
		}
	var agree = $("#agree").prop("checked");
    if( agree==false )
    {
        layer.msg('请同意.');
        return false;
    }
	$('#form1').submit();
	
}
function sendsms()
{
	
	var mobile = $('#tel').val();
	var inputCode = $('#inputCode').val();
	if(inputCode.length != 5)
		{
		layer.msg('请填验证码.');
		return false;
		}
	if(!checkMobile(mobile))
		{
	layer.msg('请填写正确的手机号.');
	return false;
		}
	
	ajaxurl('/sendsms',{mobile:mobile, code: inputCode}, function(res){
		if(res.code == 0) {
			layer.msg('短信发送成功.')
		}else{
			layer.msg('短信发送失败.')
		}
		console.log(res)
	})
}
function createCode()
{
	$('#checkCode img').attr('src', '/captcha?r='+Math.random());
}
function agree() {
	@php
	$content = \DB::table('categories')->where('id', 42)->value('content');
	@endphp
	layer.open({
		title: '《纺织品名片宝用户协议》',
		type: 1,
		  skin: 'layui-layer-rim', //加上边框
		  area: ['620px', '440px'], //宽高
		  content: '{!! $content  !!}'
		});
}



</script>

@endsection
